package com.xinchuang.common;

/**
 * TODO
 *
 * @author zkwczx
 * @version 1.0
 * @date 2021/3/19 15:19
 */
public class ResultUtil {

    public static Result success(Object object) {
        Result result = new Result();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMessage(ResultEnum.SUCCESS.getMessage());
        result.setMsg(ResultEnum.SUCCESS.getMessage());
        result.setData(object);
        return result;
    }

    public static Result success(String msg, Object object) {
        Result result = new Result();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMessage(msg);
        result.setMsg(msg);
        result.setData(object);
        return result;
    }

    public static Result success() {
        return success(null);
    }

    public static Result error(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMessage(msg);
        result.setMsg(msg);
        return result;
    }

    public static Result error(Integer code, String msg, Object obj) {
        Result result = new Result();
        result.setCode(code);
        result.setMessage(msg);
        result.setMsg(msg);
        result.setData(obj);
        return result;
    }

    public static Result error(ResultEnum resultEnum) {
        Result result = new Result();
        result.setCode(resultEnum.getCode());
        result.setMessage(resultEnum.getMessage());
        result.setMsg(resultEnum.getMessage());
        return result;
    }

}
